<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for utils\dom.js</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../prettify.css" />
    <link rel="stylesheet" href="../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="../index.html">all files</a> / <a href="index.html">utils/</a> dom.js
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">30.77% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>8/26</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">15.38% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>2/13</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">33.33% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>3/9</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">30.77% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>8/26</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">// 注册及删除监听事件
export const on = (function() {
    <span class="missing-if-branch" title="else path not taken" >E</span>if (document.addEventListener) {
        return function(el, event, handler) {
            el.addEventListener(event, handler, false)
        }
    } else <span class="cstat-no" title="statement not covered" >if (document.attachEvent) {</span>
<span class="cstat-no" title="statement not covered" >        return function(el, event, handler) <span class="fstat-no" title="function not covered" >{</span></span>
<span class="cstat-no" title="statement not covered" >            el.attachEvent('on' + event, handler)</span>
        }
    } else {
<span class="cstat-no" title="statement not covered" >        return function(el, event, handler) <span class="fstat-no" title="function not covered" >{</span></span>
<span class="cstat-no" title="statement not covered" >            el[on + 'event'] = handler</span>
        }
    }
})()
export const off = (function() {
    <span class="missing-if-branch" title="else path not taken" >E</span>if (document.removeEventListener) {
        return function(el, event, handler) <span class="fstat-no" title="function not covered" >{</span>
<span class="cstat-no" title="statement not covered" >            el.removeEventListener(event, handler, false)</span>
        }
    } else <span class="cstat-no" title="statement not covered" >if (document.detachEvent) {</span>
<span class="cstat-no" title="statement not covered" >        return function(el, event, handler) <span class="fstat-no" title="function not covered" >{</span></span>
<span class="cstat-no" title="statement not covered" >            el.detachEvent('on' + event, handler)</span>
        }
    } else {
<span class="cstat-no" title="statement not covered" >        return function(el, event, handler) <span class="fstat-no" title="function not covered" >{</span></span>
<span class="cstat-no" title="statement not covered" >            el[on + 'event'] = null</span>
        }
    }
})()
// 合并对象,并没有考虑深层次的情况
export const merge = (obj = {}, ...args) =&gt; <span class="fstat-no" title="function not covered" >{</span>
<span class="cstat-no" title="statement not covered" >    for (let i = 0, len = args.length; i &lt; len; i++) {</span>
        let tempObj = <span class="cstat-no" title="statement not covered" >args[i]</span>
<span class="cstat-no" title="statement not covered" >        if (tempObj) {</span>
<span class="cstat-no" title="statement not covered" >            for (let prop in tempObj) {</span>
<span class="cstat-no" title="statement not covered" >                if (tempObj.hasOwnProperty(prop)) {</span>
<span class="cstat-no" title="statement not covered" >                    obj[prop] = tempObj[prop]</span>
                }
            }
        }
    }
<span class="cstat-no" title="statement not covered" >    return obj</span>
}
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 15:08:50 GMT+0800 (中国标准时间)
</div>
</div>
<script src="../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../sorter.js"></script>
</body>
</html>
